package services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import models.mappers.SystemMenuMapper;

import org.apache.ibatis.session.SqlSession;

import vos.SystemMenuView;

import com.aton.db.SessionFactory;

public class IndexService {
	/**
	 * 获取菜单子节点
	 * @param operatorid 
	 *
	 * @Title: getMenu 
	 * @return: void
	 */
	public static List<SystemMenuView> getMenus(String operatorid, String parentid){
		SqlSession ss=SessionFactory.getSqlSession();
		try {
			SystemMenuMapper mapper = ss.getMapper(SystemMenuMapper.class);
			Map<String,String> map=new HashMap<String,String>();
			map.put("operatorid", operatorid);
			map.put("parentid", parentid);
            return mapper.selectChildren(map);
        } finally {
            ss.close();
        }
	}
	/**
	 * 获取父节点
	 *
	 * @Title: getMenu 
	 * @param id
	 * @return
	 * @return: SystemMenu
	 */
	public static List<SystemMenuView> getMenu(String operatorid){
		SqlSession ss=SessionFactory.getSqlSession();
		try {
			SystemMenuMapper mapper = ss.getMapper(SystemMenuMapper.class);
			List<SystemMenuView> menus=mapper.selectMenus(operatorid);
            return menus;
        } finally {
            ss.close();
        }
	}
}
